
/**
 * 分时问候
 */
function sayHello() {
	var hour = new Date().getHours();
	var hello = '';
	if(hour < 6) {
		hello = '凌晨好';
	} else if(hour < 9) {
		hello = '早上好';
	} else if(hour < 12) {
		hello = '上午好';
	} else if(hour < 14) {
		hello = '中午好';
	} else if(hour < 17) {
		hello = '下午好';
	} else if(hour < 19) {
		hello = '傍晚好';
	} else if(hour < 22) {
		hello = '晚上好';
	} else {
		hello = '夜里好';
	}
	return hello;
}
/**
 * 获得当天日期和星期
 */
function getToday() {
	WEEK_DATA_CN = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
	var today = new Date();
	var year = today.getFullYear();
	var month = today.getMonth() + 1;
	month = month < 10 ? '0' + month : month;
	var date = today.getDate();
	date = date < 10 ? '0' + date : date;
	var day = WEEK_DATA_CN[today.getDay()];
	return year + "年" + month + "月" + date + "日 " + day;
}

//退出
function exit(url) {
	$.messager.confirm('提示', '是否需要退出?', function(r) {
		if(r) {
			window.location.href = url;
		}
	});
}

$('.tpage-tree').tree({
	onClick: function(node) {
		var title = node.text;
		var url = node.url;
		var iconCls = node.iconCls;
		var iframe = node.iframe;
	
		 if($("#tab").tabs("exists",title)){
		       $("#tab").tabs("select",title);    
		 }else{
			 addTab(title, url , iconCls);
		 }
				
	}
});


//添加
function addTab(title, url, iconCls) {
	// 通过标题来判定 该tab是否出现 如果出现，就选择该tab

	// 新添加tab
	$('#tab').tabs('add', {
		title: title,
		iconCls: iconCls,
		href: url,
		closable: true
	});

}



//formatter : FDatetime
//时间转换
function FDatetime(value) {
	if(!value) return;
	var time = new Date(value);

	var year = time.getFullYear();

	var month = time.getMonth() + 1;
	month = month < 10 ? '0' + month : month;

	var date = time.getDate();
	date = date < 10 ? '0' + date : date;

	var hour = time.getHours();
	hour = hour < 10 ? '0' + hour : hour;

	var minute = time.getMinutes();
	minute = minute < 10 ? '0' + minute : minute;

	var second = time.getSeconds()
	second = second < 10 ? '0' + second : second;

	return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;

}

function FDate(value) {
	if(!value) return;
	var time = new Date(value);

	var year = time.getFullYear();

	var month = time.getMonth() + 1;
	month = month < 10 ? '0' + month : month;

	var date = time.getDate();
	date = date < 10 ? '0' + date : date;

	var hour = time.getHours();
	hour = hour < 10 ? '0' + hour : hour;

	var minute = time.getMinutes();
	minute = minute < 10 ? '0' + minute : minute;

	var second = time.getSeconds()
	second = second < 10 ? '0' + second : second;

	return year + "-" + month + "-" + date;

}




//是否可用  
function FIsuse(value) {

	if(value == 1) {
		return "启用";
	} else {
		return "关闭";
	}
}

//用户角色 
function FRole(value) {

	if(value == 1) {
		return "管理";
	} else {
		return "成员";
	}
}